package com.huawei.codearts.rowmapper;

import com.huawei.codearts.model.Order;

import org.springframework.jdbc.core.RowMapper;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * JdbcTemplate 映射实体类  字段到实体映射抽出来单独维护
 */

public class OrderRowMapper implements RowMapper<Order> {
    @Override
    public Order mapRow(ResultSet rs, int rowNum) throws SQLException {
        // 在这里做字段到实体的映射
        Order o = new Order();
        o.setId(rs.getInt("id"));
        o.setNumber(rs.getString("number"));
        o.setSort(rs.getString("sort"));
        o.setMemberId(rs.getInt("member_id"));
        o.setMemberName(rs.getString("membername"));
        o.setPrice(rs.getBigDecimal("price"));
        o.setCreateTime(rs.getLong("createtime"));
        return o;
    }
}
